import antfu from "@antfu/eslint-config";

export default antfu({
    type: "lib",
    typescript: true, // 启用 TypeScript 支持
    stylistic: {
        indent: 4, // 缩进使用 4 个空格
        semi: true, // 使用分号
        quotes: "double", // or 'single'
    },
    // 你可以在这里添加或覆盖规则
    rules: {
        "style/comma-dangle": ["error", "always-multiline"],
        "vue/comma-dangle": ["error", "never"],
        "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
        "vue/brace-style": ["error", "1tbs", { allowSingleLine: true }],
        "vue/block-order": ["error", { order: ["script", "template", "style"] }],

        "no-console": ["warn", { allow: ["info", "warn", "error"] }],
        "no-case-declarations": "warn",
        "no-throw-literal": "warn",
        "vue/html-self-closing": ["warn", { html: { void: "always" } }],
        "node/prefer-global/process": ["warn", "always"],

        "no-use-before-define": "off",
        "ts/no-use-before-define": "off",
        "one-var": "off",
        "antfu/if-newline": "off",
        "antfu/top-level-function": "off",
        "ts/ban-ts-comment": "off",
        "ts/no-empty-function": "off",
        "jsdoc/require-returns-description": "off",
        "regexp/no-unused-capturing-group": "off",

        // 导入路径限制
        "no-restricted-imports": [
            "error",
            {
                patterns: [
                    {
                        /** 规范请求类型导入 */
                        group: ["**/types/**/req*", "**/types/**/res*"],
                        message: "请使用 '@/api/types' 统一导入!",
                    },
                    {
                        /** 规范请求接口导入 */
                        group: ["*/api/module/*"],
                        message: "请使用 '@/api' 统一导入!",
                    },
                    {
                        /** 规范工具类导入, 使用统一导入 */
                        group: ["*/utils/tools/**"],
                        message: "请使用 '@/utils/tools' 统一导入!",
                    },
                    {
                        /** 规范 composables 的导入, 使用统一导入 */
                        group: ["*/composables/**"],
                        message: "请使用 '*/composables' 统一导入!",
                    },
                ],
            },
        ],
    },
    ignores: [
        "dist",
        "node_modules",
        "**/*.d.ts",
        ".vscode",
        ".husky",
        "**/*.md",
        "stats.html",
    ],
});
